package com.polaris.live.ui.live.widget.adapter

import com.polaris.live.R
import com.polaris.live.adapter.live.LiveMessageAdapter
import com.polaris.live.databinding.LiveMessageInviteSeatItemBinding
import com.polaris.live.im.sfs.bean.live.SendLiveMessage
import com.polaris.live.im.sfs.bean.live.ext.MessageUserExtBean
import com.polaris.live.ui.message.widget.single_message.AbstractLiveMessageItemHolder
import com.polaris.live.widget.avatar.FrameImageUtils

/**
 * 邀请上座消息
 * @author Created by 天晴 on 2024/3/8 14:59
 * @since 1.0.0
 **/
class LiveMessageUpSeatItem(
    adapter: LiveMessageAdapter,
    binding: LiveMessageInviteSeatItemBinding,
) : AbstractLiveMessageItemHolder<LiveMessageInviteSeatItemBinding>(adapter, binding) {

    override fun bind(item: SendLiveMessage) {
        mBinding.apply {
            val ext = item.ext as? MessageUserExtBean?
            if (ext != null) {
                callUpSeatText.text = item.content

                callFollowerUserHead.setImageUrl(ext.user.avatar, ext.user.userId)
                avFv.setFrameImage(FrameImageUtils.urlToFrameImageBean(ext.user.avatarFrame))
                callUpSeatIm.setImageResource(R.drawable.btn_shangmai)
            } else {
                callUpSeatText.text = ""
                avFv.setFrameImage(null)

                callFollowerUserHead.setImageUrl(null)
                callUpSeatIm.setImageResource(0)
            }
        }
    }
}